﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Shared.xaml" />
        <ResourceDictionary Source="PaneHeaderCommandStyle.xaml" />
        <ResourceDictionary Source="DockableContentTabItemStyle.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type ad:DockablePane}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ad:DockablePane}">
                    <Border Focusable="True" Background="{StaticResource Brush_WindowBackground}" BorderBrush="{StaticResource Brush_PaneBorder}" BorderThickness="1" CornerRadius="3" Margin="5" Padding="5">
                        <Grid FocusManager.FocusedElement="{Binding ElementName=PART_SelectedContent}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="18"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel x:Name="PART_Header" LastChildFill="True" Grid.Row="0">
                                <Button DockPanel.Dock="Right" Style="{StaticResource PaneHeaderCommandStyle}" Command="ad:DockablePane.CloseCommand"
                                            Width="15" Height="15" Margin="2,0,2,0" VerticalAlignment="Center">
                                    <ad:AlignedImage>
                                        <Image x:Name="IMG_Close" Source="/AvalonDock;component/resources/Images/Classic/PinClose.png" Width="13" Height="13" Stretch="UniformToFill"/>
                                    </ad:AlignedImage>
                                </Button>
                                <Button x:Name="btnPinAutoHide" DockPanel.Dock="Right" Style="{StaticResource PaneHeaderCommandStyle}" Command="ad:DockablePane.ToggleAutoHideCommand"
                                            Width="15" Height="15" VerticalAlignment="Center">
                                    <ad:AlignedImage>
                                        <Image x:Name="IMG_AutoHide" Source="/AvalonDock;component/resources/Images/Classic/PinAutoHide.png" Width="13" Height="13" Stretch="UniformToFill"/>
                                    </ad:AlignedImage>
                                </Button>
                                <Button x:Name="PART_ShowContextMenuButton"  DockPanel.Dock="Right" Style="{StaticResource PaneHeaderContextMenuCommandStyle}" Command="ad:DockablePane.ShowOptionsCommand"
                                            Width="15" Height="15" VerticalAlignment="Center">
                                    <ad:AlignedImage>
                                        <Image x:Name="IMG_ShowContextMenu" Source="/AvalonDock;component/resources/Images/Classic/PinMenu.png" Width="13" Height="13" Stretch="UniformToFill"/>
                                    </ad:AlignedImage>
                                </Button>
                                <TextBlock 
									    Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Title}" 
									    x:Name="paneTitle"
									    Grid.Row="0" 
									    Margin="2,0,0,0" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap"
                                        VerticalAlignment="Center"
									    Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DockablePaneTitleForeground}}}"/>
								</DockPanel>
                            <ContentPresenter 
                                    x:Name="PART_SelectedContent"
                                    Grid.Row="1"
                                    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Content}"
								    KeyboardNavigation.TabNavigation="Local"
								    KeyboardNavigation.DirectionalNavigation="Contained"
								    KeyboardNavigation.TabIndex="1"
                                    />
                            <Border x:Name="PART_Tabs"
                                    Grid.Row="2" 
								    Margin ="0,2,0,0" 
                                    Height ="23" 
								    BorderThickness="0,1,0,0" 
								    BorderBrush="{DynamicResource Brush_ControlBackground}">
                            </Border>
                            <ad:DockableTabPanel
                                    Grid.Row="2" 
                                    Height ="22" 
                                    KeyboardNavigation.TabIndex="2"								
                                    IsItemsHost="True" 
                                    x:Name="paneTabsPanel" 
                                    Margin="0,0,0,2"
                                    TabItemStyle="{StaticResource DockableContentTabItemStyle}"/>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.IsActiveContent}" Value="True" >
                            <!--Setter Property="Background" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DockablePaneTitleBackgroundSelected}}}" TargetName="PART_Header"/-->
                            <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DockablePaneTitleForegroundSelected}}}" TargetName="paneTitle"/>
                            <Setter Property="Source" Value="/AvalonDock;component/resources/Images/Classic/PinMenuSelected.png" TargetName="IMG_ShowContextMenu"/>
                            <Setter Property="Source" Value="/AvalonDock;component/resources/Images/Classic/PinAutoHideSelected.png" TargetName="IMG_AutoHide"/>
                            <Setter Property="Source" Value="/AvalonDock;component/resources/Images/Classic/PinCloseSelected.png" TargetName="IMG_Close"/>
                        </DataTrigger>
                        <Trigger Property ="ShowHeader" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Header"/>
                        </Trigger>
                        <Trigger Property ="ShowTabs" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Tabs"/>
                        </Trigger>
                        <Trigger Property ="HasSingleItem" Value="True">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Tabs"/>
                            <Setter Property="Visibility" Value="Collapsed" TargetName="paneTabsPanel"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},  Path=SelectedItem.State}" Value="AutoHide">
                            <Setter Property="LayoutTransform" TargetName="btnPinAutoHide">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>